use multi_support_app::{test_server::TestServer, user_server::UserServer};
use tower_http::trace::TraceLayer;
use tracing::Level;
use tower_http::trace;

use crate::service::{test::TestService, user::UserService};


pub(crate) fn register() -> tonic::transport::server::Router<tower::layer::util::Stack<TraceLayer<tower_http::classify::SharedClassifier<tower_http::classify::GrpcErrorsAsFailures>>, tower::layer::util::Identity>> {
    // layer trace
    let layer_trace = TraceLayer::new_for_grpc()
        .make_span_with(trace::DefaultMakeSpan::new().level(Level::INFO))
        .on_request(trace::DefaultOnRequest::new().level(Level::INFO))
        .on_response(trace::DefaultOnResponse::new().level(Level::INFO));
    // grpc router
    tonic::transport::Server::builder()
        .layer(layer_trace)
        .add_service(TestServer::new(TestService))
        .add_service(UserServer::new(UserService))
}